# -*- coding: utf-8 -*-
##############################################################################
#
#    OpenERP, Open Source Management Solution
#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time

from openerp import SUPERUSER_ID
from openerp.osv import fields, osv

class hr_contract_type(osv.osv):
    
    _inherit = "hr.contract"
    _description = 'Contract'
    
    _columns = {
        'status': fields.boolean('Active'),
        'stat': fields.char('Contract Status', readonly=True),
        'incentive': fields.many2one('hr.master.salary', 'Incentive'),
        'meal': fields.related('incentive', 'meal', type='float', string='Meal Allowance', readonly=True),
        'transport': fields.related('incentive', 'transport', type='float', string='Transport Allowance', readonly=True),
        'ot_type': fields.selection([('incentive','Incentive'),('overtime', 'Overtime')], 'Overtime Type'),
        'shift_group': fields.many2one('hr.employs.group', 'Shift Group'),
        'contract_project_ids': fields.one2many('hr.contract.project','contract_project_id', 'Project Contract'),
        }
    
    _defaults = {
        'stat': "Open",
    }
    
class hr_contract_type(osv.osv):
    
    _inherit = "hr.contract.type"
    _description = 'Contract Type'
    
    _columns = {
        'is_have_allocation': fields.boolean('Leave Allocation'),
        'bpjs_worker': fields.float('Worker Contribution (%)'),
        'bpjs_company': fields.float('Company Contribution (%)'),
        'medical_reimburse': fields.float('Yearly Medical Allowance'),
        'limit_medical_reimburse': fields.float('Limit Medical Allowance'),
        'professional_tax': fields.float('Professional Tax (%)'),
        'nominal_professional_tax': fields.float('Nominal (Rp)'),
        'company_annuity': fields.float('Company Annuity (%)'),
        'worker_annuity': fields.float('Worker Annuity (%)'),
        'nominal_annuity': fields.float('Nominal Annuity (Rp)'),
        'tax_calc_type': fields.selection([('net','Net'),('gross_up', 'Gross Up'),('mix', 'Mix')],'Tax Calculation Type', required=True),
    }

class hr_contract_project(osv.osv):
    
    _name = "hr.contract.project"
    
    _columns = {
        'contract_project_id': fields.many2one('hr.contract', 'Project Contract', select=False, ondelete='cascade'),
        'name': fields.char('Project Name', required=True),
        'project_start_date': fields.date('Start Date'),
        'project_end_date': fields.date('End Date'),
        'location': fields.char('Location'),
        'work_hours': fields.many2one('resource.calendar', 'Working Time'),
        'project_allowance': fields.char('Project Allowance (%)'),
        'other_allowance_id': fields.many2one('hr.project.allowance', 'Other Allowance'),
        'project_status': fields.boolean('Status'),
    }
    
class hr_project_allowance(osv.osv):
    
    _name = "hr.project.allowance"
    
    _columns = {
        'name': fields.char('Allowance Name', required=True),
        'ord_ot_allowance': fields.float('Ordinary OT Allowance'),
        'ot_meal_allowance': fields.float('OT Meal Allowance'),
        'holiday_ot_allowance': fields.float('Holiday OT Allowance'),
        'ord_meal_allowance': fields.float('Meal Allowance'),
    }
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
